&ANALYZE-SUSPEND _VERSION-NUMBER AB_v10r12 GUI adm2
&ANALYZE-RESUME
&Scoped-define WINDOW-NAME CURRENT-WINDOW


/* Temp-Table and Buffer definitions                                    */
DEFINE TEMP-TABLE ab_unmap
       FIELD article_bas AS CHARACTER FORMAT "X(256)":U 
       FIELD article_ent AS CHARACTER FORMAT "X(256)":U 
       FIELD article_sais AS CHARACTER FORMAT "X(256)":U 
       FIELD client AS CHARACTER FORMAT "X(256)":U 
       FIELD lab_cli AS CHARACTER FORMAT "X(256)":U 
       FIELD Lab_com AS CHARACTER FORMAT "X(256)":U 
       FIELD lab_livr AS CHARACTER FORMAT "X(256)":U 
       FIELD lab_mail AS CHARACTER FORMAT "X(256)":U 
       FIELD lab_mess AS CHARACTER FORMAT "X(256)":U 
       FIELD lab_ref AS CHARACTER FORMAT "X(256)":U 
       FIELD livr AS CHARACTER FORMAT "X(256)":U 
       FIELD mail AS CHARACTER FORMAT "X(256)":U 
       FIELD mess AS CHARACTER FORMAT "X(256)":U 
       FIELD Num_com AS CHARACTER FORMAT "X(256)":U 
       FIELD ref AS CHARACTER FORMAT "X(256)":U 
       FIELD texte01 AS CHARACTER FORMAT "X(256)":U 
       FIELD texte02 AS CHARACTER FORMAT "X(256)":U 
       FIELD texte03 AS CHARACTER FORMAT "X(256)":U 
       FIELD texte04 AS CHARACTER FORMAT "X(256)":U 
       FIELD texte05 AS CHARACTER FORMAT "X(256)":U 
       FIELD texte06 AS CHARACTER FORMAT "X(256)":U 
       FIELD texte07 AS CHARACTER FORMAT "X(256)":U 
       FIELD texte08 AS CHARACTER FORMAT "X(256)":U 
       FIELD texte09 AS CHARACTER FORMAT "X(256)":U 
       FIELD texte10 AS CHARACTER FORMAT "X(256)":U .



&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS w-html 
/*------------------------------------------------------------------------

  File: 

  Description: 

  Input Parameters:
      <none>

  Output Parameters:
      <none>

  Author: 

  Created: 

------------------------------------------------------------------------*/
/*           This .W file was created with AppBuilder.                  */
/*----------------------------------------------------------------------*/

/* Create an unnamed pool to store all the widgets created 
     by this procedure. This is a good default which assures
     that this procedure's triggers and internal procedures 
     will execute in this procedure's storage, and that proper
     cleanup will occur on deletion of the procedure. */
CREATE WIDGET-POOL.

/* ***************************  Definitions  ************************** */

/* Preprocessor Definitions ---                                         */

/* Parameters Definitions ---                                           */

/* Local Variable Definitions ---                                       */


DEF NEW SHARED BUFFER wk-doce  FOR doce.
DEF NEW SHARED BUFFER doce     FOR doce.
DEF NEW SHARED BUFFER docld    FOR docld.

DEF NEW SHARED VAR a-lang          AS    INTEGER                   NO-UNDO.
DEF            VAR i               AS    INTEGER                   NO-UNDO.
DEF            VAR j               AS    INTEGER                   NO-UNDO.
DEF            VAR ind             AS    INTEGER                   NO-UNDO.
DEF            VAR sav-lang        AS    INTEGER                   NO-UNDO.

DEF            VAR buf-noadr       LIKE doce.noadrf                NO-UNDO.
DEF            VAR buf-csmt        LIKE doce.csmtf                 NO-UNDO.
DEF            VAR buf-typdoc      LIKE doce.typdoc                NO-UNDO.
DEF            VAR buf-prefix      LIKE doce.prefix                NO-UNDO.
DEF            VAR cde-prefix      LIKE doce.prefix                NO-UNDO.

DEF            VAR buf-nodoc       LIKE doce.nodoc                 NO-UNDO.
DEF            VAR last-nodoc      LIKE doce.nodoc                 NO-UNDO.

DEF            VAR buf-esc         LIKE adrd.esc                   NO-UNDO.
DEF            VAR buf-echesc      LIKE adrd.echesc                NO-UNDO.
DEF            VAR buf-echnet      LIKE adrd.echne                 NO-UNDO.
DEF            VAR buf-echle       LIKE adrd.echle                 NO-UNDO.
DEF            VAR buf-parmt       AS   CHARACTER                  NO-UNDO.
DEF            VAR buf-lib         AS   CHARACTER                  NO-UNDO.

DEF            VAR flag-lgdoc      AS   LOGICAL                    NO-UNDO.
DEF            VAR flag-art        AS   LOGICAL                    NO-UNDO.

DEF            VAR buf-adresse     AS   CHARACTER                  NO-UNDO.
DEF            VAR buf-adressel    AS   CHARACTER                  NO-UNDO.
DEF            VAR buf-adressef    AS   CHARACTER                  NO-UNDO.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK 

/* ********************  Preprocessor Definitions  ******************** */

&Scoped-define PROCEDURE-TYPE Web-Object
&Scoped-define DB-AWARE no

&Scoped-define WEB-FILE commande_valid.htm

/* Name of designated FRAME-NAME and/or first browse and/or first query */
&Scoped-define FRAME-NAME Web-Frame

/* Standard List Definitions                                            */
&Scoped-Define ENABLED-OBJECTS ab_unmap.mail ab_unmap.client ~
ab_unmap.lab_cli ab_unmap.lab_livr ab_unmap.lab_mail ab_unmap.lab_mess ~
ab_unmap.lab_ref ab_unmap.livr ab_unmap.mess ab_unmap.ref ~
ab_unmap.article_bas ab_unmap.article_ent ab_unmap.article_sais ~
ab_unmap.texte01 ab_unmap.texte02 ab_unmap.texte03 ab_unmap.texte04 ~
ab_unmap.texte05 ab_unmap.texte06 ab_unmap.texte07 ab_unmap.texte08 ~
ab_unmap.texte09 ab_unmap.texte10 ab_unmap.Lab_com ab_unmap.Num_com 
&Scoped-Define DISPLAYED-OBJECTS ab_unmap.mail ab_unmap.client ~
ab_unmap.lab_cli ab_unmap.lab_livr ab_unmap.lab_mail ab_unmap.lab_mess ~
ab_unmap.lab_ref ab_unmap.livr ab_unmap.mess ab_unmap.ref ~
ab_unmap.article_bas ab_unmap.article_ent ab_unmap.article_sais ~
ab_unmap.texte01 ab_unmap.texte02 ab_unmap.texte03 ab_unmap.texte04 ~
ab_unmap.texte05 ab_unmap.texte06 ab_unmap.texte07 ab_unmap.texte08 ~
ab_unmap.texte09 ab_unmap.texte10 ab_unmap.Lab_com ab_unmap.Num_com 

/* Custom List Definitions                                              */
/* List-1,List-2,List-3,List-4,List-5,List-6                            */

/* _UIB-PREPROCESSOR-BLOCK-END */
&ANALYZE-RESUME



/* ***********************  Control Definitions  ********************** */


/* Definitions of the field level widgets                               */

/* ************************  Frame Definitions  *********************** */

DEFINE FRAME Web-Frame
     ab_unmap.mail AT ROW 1 COL 1 HELP
          "" NO-LABEL FORMAT "X(256)":U
          VIEW-AS FILL-IN 
          SIZE 20 BY 1
     ab_unmap.client AT ROW 1 COL 1 HELP
          "" NO-LABEL FORMAT "X(256)":U
          VIEW-AS FILL-IN 
          SIZE 20 BY 1
     ab_unmap.lab_cli AT ROW 1 COL 1 HELP
          "" NO-LABEL FORMAT "X(256)":U
          VIEW-AS FILL-IN 
          SIZE 20 BY 1
     ab_unmap.lab_livr AT ROW 1 COL 1 HELP
          "" NO-LABEL FORMAT "X(256)":U
          VIEW-AS FILL-IN 
          SIZE 20 BY 1
     ab_unmap.lab_mail AT ROW 1 COL 1 HELP
          "" NO-LABEL FORMAT "X(256)":U
          VIEW-AS FILL-IN 
          SIZE 20 BY 1
     ab_unmap.lab_mess AT ROW 1 COL 1 HELP
          "" NO-LABEL FORMAT "X(256)":U
          VIEW-AS FILL-IN 
          SIZE 20 BY 1
     ab_unmap.lab_ref AT ROW 1 COL 1 HELP
          "" NO-LABEL FORMAT "X(256)":U
          VIEW-AS FILL-IN 
          SIZE 20 BY 1
     ab_unmap.livr AT ROW 1 COL 1 HELP
          "" NO-LABEL FORMAT "X(256)":U
          VIEW-AS FILL-IN 
          SIZE 20 BY 1
     ab_unmap.mess AT ROW 1 COL 1 HELP
          "" NO-LABEL FORMAT "X(256)":U
          VIEW-AS FILL-IN 
          SIZE 20 BY 1
     ab_unmap.ref AT ROW 1 COL 1 HELP
          "" NO-LABEL FORMAT "X(256)":U
          VIEW-AS FILL-IN 
          SIZE 20 BY 1
     ab_unmap.article_bas AT ROW 1 COL 1 HELP
          "" NO-LABEL FORMAT "X(256)":U
          VIEW-AS FILL-IN 
          SIZE 20 BY 1
     ab_unmap.article_ent AT ROW 1 COL 1 HELP
          "" NO-LABEL FORMAT "X(256)":U
          VIEW-AS FILL-IN 
          SIZE 20 BY 1
     ab_unmap.article_sais AT ROW 1 COL 1 HELP
          "" NO-LABEL FORMAT "X(256)":U
          VIEW-AS FILL-IN 
          SIZE 20 BY 1
     ab_unmap.texte01 AT ROW 1 COL 1 HELP
          "" NO-LABEL FORMAT "X(256)":U
          VIEW-AS FILL-IN 
          SIZE 20 BY 1
     ab_unmap.texte02 AT ROW 1 COL 1 HELP
          "" NO-LABEL FORMAT "X(256)":U
          VIEW-AS FILL-IN 
          SIZE 20 BY 1
     ab_unmap.texte03 AT ROW 1 COL 1 HELP
          "" NO-LABEL FORMAT "X(256)":U
          VIEW-AS FILL-IN 
          SIZE 20 BY 1
     ab_unmap.texte04 AT ROW 1 COL 1 HELP
          "" NO-LABEL FORMAT "X(256)":U
          VIEW-AS FILL-IN 
          SIZE 20 BY 1
     ab_unmap.texte05 AT ROW 1 COL 1 HELP
          "" NO-LABEL FORMAT "X(256)":U
          VIEW-AS FILL-IN 
          SIZE 20 BY 1
     ab_unmap.texte06 AT ROW 1 COL 1 HELP
          "" NO-LABEL FORMAT "X(256)":U
          VIEW-AS FILL-IN 
          SIZE 20 BY 1
     ab_unmap.texte07 AT ROW 1 COL 1 HELP
          "" NO-LABEL FORMAT "X(256)":U
          VIEW-AS FILL-IN 
          SIZE 20 BY 1
     ab_unmap.texte08 AT ROW 1 COL 1 HELP
          "" NO-LABEL FORMAT "X(256)":U
          VIEW-AS FILL-IN 
          SIZE 20 BY 1
     ab_unmap.texte09 AT ROW 1 COL 1 HELP
          "" NO-LABEL FORMAT "X(256)":U
          VIEW-AS FILL-IN 
          SIZE 20 BY 1
     ab_unmap.texte10 AT ROW 1 COL 1 HELP
          "" NO-LABEL FORMAT "X(256)":U
          VIEW-AS FILL-IN 
          SIZE 20 BY 1
     ab_unmap.Lab_com AT ROW 1 COL 1 HELP
          "" NO-LABEL FORMAT "X(256)":U
          VIEW-AS FILL-IN 
          SIZE 20 BY 1
     ab_unmap.Num_com AT ROW 1 COL 1 HELP
          "" NO-LABEL FORMAT "X(256)":U
          VIEW-AS FILL-IN 
          SIZE 20 BY 1
    WITH 1 DOWN KEEP-TAB-ORDER OVERLAY 
         SIDE-LABELS 
         AT COL 1 ROW 1
         SIZE 60.63 BY 14.13.


/* *********************** Procedure Settings ************************ */

&ANALYZE-SUSPEND _PROCEDURE-SETTINGS
/* Settings for THIS-PROCEDURE
   Type: Web-Object
   Allow: Query
   Frames: 1
   Add Fields to: Neither
   Editing: Special-Events-Only
   Events: web.output,web.input
   Other Settings: COMPILE
   Temp-Tables and Buffers:
      TABLE: ab_unmap W "?" ?  
      ADDITIONAL-FIELDS:
          FIELD article_bas AS CHARACTER FORMAT "X(256)":U 
          FIELD article_ent AS CHARACTER FORMAT "X(256)":U 
          FIELD article_sais AS CHARACTER FORMAT "X(256)":U 
          FIELD client AS CHARACTER FORMAT "X(256)":U 
          FIELD lab_cli AS CHARACTER FORMAT "X(256)":U 
          FIELD Lab_com AS CHARACTER FORMAT "X(256)":U 
          FIELD lab_livr AS CHARACTER FORMAT "X(256)":U 
          FIELD lab_mail AS CHARACTER FORMAT "X(256)":U 
          FIELD lab_mess AS CHARACTER FORMAT "X(256)":U 
          FIELD lab_ref AS CHARACTER FORMAT "X(256)":U 
          FIELD livr AS CHARACTER FORMAT "X(256)":U 
          FIELD mail AS CHARACTER FORMAT "X(256)":U 
          FIELD mess AS CHARACTER FORMAT "X(256)":U 
          FIELD Num_com AS CHARACTER FORMAT "X(256)":U 
          FIELD ref AS CHARACTER FORMAT "X(256)":U 
          FIELD texte01 AS CHARACTER FORMAT "X(256)":U 
          FIELD texte02 AS CHARACTER FORMAT "X(256)":U 
          FIELD texte03 AS CHARACTER FORMAT "X(256)":U 
          FIELD texte04 AS CHARACTER FORMAT "X(256)":U 
          FIELD texte05 AS CHARACTER FORMAT "X(256)":U 
          FIELD texte06 AS CHARACTER FORMAT "X(256)":U 
          FIELD texte07 AS CHARACTER FORMAT "X(256)":U 
          FIELD texte08 AS CHARACTER FORMAT "X(256)":U 
          FIELD texte09 AS CHARACTER FORMAT "X(256)":U 
          FIELD texte10 AS CHARACTER FORMAT "X(256)":U 
      END-FIELDS.
   END-TABLES.
 */
&ANALYZE-RESUME _END-PROCEDURE-SETTINGS

/* *************************  Create Window  ************************** */

&ANALYZE-SUSPEND _CREATE-WINDOW
/* DESIGN Window definition (used by the UIB) 
  CREATE WINDOW w-html ASSIGN
         HEIGHT             = 14.13
         WIDTH              = 60.63.
/* END WINDOW DEFINITION */
                                                                        */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB w-html 
/* *********************** Included-Libraries ************************* */

{src/web2/html-map.i}

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME




/* ***********  Runtime Attributes and AppBuilder Settings  *********** */

&ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
/* SETTINGS FOR WINDOW w-html
  VISIBLE,,RUN-PERSISTENT                                               */
/* SETTINGS FOR FRAME Web-Frame
   FRAME-NAME UNDERLINE                                                 */
/* SETTINGS FOR FILL-IN ab_unmap.article_bas IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.article_ent IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.article_sais IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.client IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.lab_cli IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.Lab_com IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.lab_livr IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.lab_mail IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.lab_mess IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.lab_ref IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.livr IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.mail IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.mess IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.Num_com IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.ref IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.texte01 IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.texte02 IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.texte03 IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.texte04 IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.texte05 IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.texte06 IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.texte07 IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.texte08 IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.texte09 IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.texte10 IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* _RUN-TIME-ATTRIBUTES-END */
&ANALYZE-RESUME

 



/* ************************  Control Triggers  ************************ */

&Scoped-define SELF-NAME ab_unmap.article_bas
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ab_unmap.article_bas w-html WEB.output
PROCEDURE ab_unmap.article_bas.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  DEF VAR nom_page        AS    CHARACTER         NO-UNDO.
  DEF VAR ligne           AS    CHARACTER         NO-UNDO.
  DEF VAR lst-tag         AS    CHARACTER         NO-UNDO.
  DEF VAR pos             AS    INTEGER           NO-UNDO.
  DEF VAR txt_aff         AS    CHARACTER         NO-UNDO.

  DO WITH FRAME {&FRAME-NAME}:
  
      IF NOT flag-lgdoc THEN RETURN.

      txt_aff = "".

      FIND erreur WHERE erreur.noerr = 101057
                    AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
      txt_aff = txt_aff + IF NOT AVAILABLE erreur THEN "&nbsp;"
                          ELSE erreur.libel.

      FIND erreur WHERE erreur.noerr = 101012
                    AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
      txt_aff = txt_aff + "#" + erreur.libel
              + "#" + STRING(doce.totme - doce.totqte - doce.totmtn + doce.totme,"->>>,>>9.99").

      FIND erreur WHERE erreur.noerr = 101058
                    AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
      txt_aff = txt_aff + "#" + IF NOT AVAILABLE erreur THEN "&nbsp;"
                          ELSE erreur.libel.

      FIND erreur WHERE erreur.noerr = 101014
                    AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
      txt_aff = txt_aff + "#" + erreur.libel
              + "#" + STRING(doce.totqte + doce.totmtn - doce.totme,"->>>,>>9.99").

      FIND erreur WHERE erreur.noerr = 101059
                    AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
      txt_aff = txt_aff + "#" + IF NOT AVAILABLE erreur THEN "&nbsp;"
                          ELSE erreur.libel.

      FIND erreur WHERE erreur.noerr = 101013
                    AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
      txt_aff = txt_aff + "#" + erreur.libel
              + "#" + STRING(doce.totme,"->>>,>>9.99").

      txt_aff = txt_aff + "#" + doce.codmon.

      nom_page = SEARCH("commande_bas.htm").
      IF nom_page = ? THEN RETURN.
      INPUT FROM VALUE(nom_page).
      REPEAT:
         IMPORT UNFORMATTED ligne.
         pos = INDEX(ligne,"<!--WSTAG").
         IF TRIM(ligne) BEGINS "<!--" AND pos = 0 THEN NEXT.
         IF pos = 0 THEN {&out} ligne SKIP.
         ELSE DO:
            RUN decode_tag(ligne,"champ",OUTPUT lst-tag).
            DO i = 1 TO NUM-ENTRIES(lst-tag).
               RUN remplace_tag ("champ",10,ENTRY(i,lst-tag),txt_aff,INPUT-OUTPUT ligne).
            END.
            {&out} ligne SKIP.
         END.
      END.
  END.
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME ab_unmap.article_ent
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ab_unmap.article_ent w-html WEB.output
PROCEDURE ab_unmap.article_ent.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  DEF VAR nom_page        AS CHARACTER      NO-UNDO.
  DEF VAR ligne           AS CHARACTER      NO-UNDO.
  DEF VAR lst-tag         AS CHARACTER      NO-UNDO.
  DEF VAR pos             AS INTEGER        NO-UNDO.
  DEF VAR nb              AS INTEGER        NO-UNDO.
  DEF VAR buf-mess        AS CHARACTER      NO-UNDO.
  
  DO WITH FRAME {&FRAME-NAME}:
      buf-mess = "".

      IF NOT flag-lgdoc THEN DO:
         FIND erreur WHERE erreur.noerr = 101054
                       AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
         IF AVAILABLE erreur THEN buf-mess = buf-mess + erreur.libel.
         nom_page = SEARCH("commande_vide.htm").
      END.
      ELSE DO:
         FIND erreur WHERE erreur.noerr = 101009
                        AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
         IF AVAILABLE erreur THEN buf-mess = buf-mess + erreur.libel.
         nom_page = SEARCH("commande_entete.htm").
         buf-mess = buf-mess + "####" .
      END.

      nb = NUM-ENTRIES(buf-mess,"#").

      IF nom_page = ? THEN RETURN.
      INPUT FROM VALUE(nom_page).
      REPEAT:
         IMPORT UNFORMATTED ligne.
         pos = INDEX(ligne,"<!--WSTAG").
         IF TRIM(ligne) BEGINS "<!--" AND pos = 0 THEN NEXT.
         IF pos = 0 THEN {&out} ligne SKIP.
         ELSE DO:
            RUN decode_tag(ligne,"label",OUTPUT lst-tag).
            DO i = 1 TO NUM-ENTRIES(lst-tag).
               RUN remplace_tag ("label",nb,ENTRY(i,lst-tag),buf-mess,INPUT-OUTPUT ligne).
            END.
            {&out} ligne SKIP.
         END.
      END.
  END.
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME ab_unmap.article_sais
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ab_unmap.article_sais w-html WEB.output
PROCEDURE ab_unmap.article_sais.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  DEF VAR flag-trouve     AS    LOGICAL           NO-UNDO.
  DEF VAR txt_aff         AS    CHARACTER         NO-UNDO.
  DEF VAR nom_page        AS    CHARACTER         NO-UNDO.
  DEF VAR ligne           AS    CHARACTER         NO-UNDO.
  DEF VAR lst-tag         AS    CHARACTER         NO-UNDO.
  DEF VAR pos             AS    INTEGER           NO-UNDO.
  DEF VAR i               AS    INTEGER           NO-UNDO.
  DEF VAR num             AS    INTEGER           NO-UNDO.
  
  FOR EACH docld WHERE docld.nosoc  = doce.nosoc
                   AND docld.typdoc = doce.typdoc
                   AND docld.prefix = doce.prefix
                   AND docld.nodoc  = doce.nodoc NO-LOCK:
      IF docld.ref = "" THEN NEXT.

      FIND arti WHERE arti.nosoc = docld.nosoc
                  AND arti.ref   = docld.ref NO-LOCK NO-ERROR.

      IF NOT AVAILABLE arti THEN NEXT.
      flag-art = TRUE.

      txt_aff = "&nbsp;".
      txt_aff = txt_aff + "#" + STRING(docld.qtec).
      txt_aff = txt_aff + "#" + arti.titre + "#" + arti.auteur + "#" + ENTRY(1,arti.DESCRIPTION,CHR(10)).
      txt_aff = txt_aff + "#" + STRING(docld.punite,"zz,zz9.99").
      txt_aff = txt_aff + "#" + STRING(docld.rabais,"zz9.99 %").
      txt_aff = txt_aff + "#" + STRING(docld.montne,"zzz,zz9.99").
      txt_aff = txt_aff + "#" + doce.codmon + "#" + docld.ref.

      nom_page = SEARCH("commande_ligne.htm").
      IF nom_page = ? THEN RETURN.
      INPUT FROM VALUE(nom_page).
      REPEAT:
         IMPORT UNFORMATTED ligne.
         pos = INDEX(ligne,"<!--WSTAG").
         IF TRIM(ligne) BEGINS "<!--" AND pos = 0 THEN NEXT.
         IF pos = 0 THEN {&out} ligne SKIP.
         ELSE DO:
            RUN decode_tag(ligne,"champ",OUTPUT lst-tag).
            DO i = 1 TO NUM-ENTRIES(lst-tag).
               RUN remplace_tag ("champ",10,ENTRY(i,lst-tag),txt_aff,INPUT-OUTPUT ligne).
            END.
            {&out} ligne SKIP.
         END.
      END.
  END.
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME ab_unmap.client
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ab_unmap.client w-html WEB.output
PROCEDURE ab_unmap.client.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  DO WITH FRAME {&FRAME-NAME}:
     {&out} REPLACE(buf-adressef,CHR(10),"<br>").
  END.
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME ab_unmap.lab_cli
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ab_unmap.lab_cli w-html WEB.output
PROCEDURE ab_unmap.lab_cli.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  DO WITH FRAME {&FRAME-NAME}:
      RUN aff_label(101090).
  END.
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME ab_unmap.Lab_com
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ab_unmap.Lab_com w-html WEB.output
PROCEDURE ab_unmap.Lab_com.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  DO WITH FRAME {&FRAME-NAME}:
     FIND erreur WHERE erreur.noerr = 101046
                   AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
     {&out} erreur.libel.
  END.
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME ab_unmap.lab_livr
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ab_unmap.lab_livr w-html WEB.output
PROCEDURE ab_unmap.lab_livr.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  DO WITH FRAME {&FRAME-NAME}:
      RUN aff_label(101091).
  END.
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME ab_unmap.lab_mail
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ab_unmap.lab_mail w-html WEB.output
PROCEDURE ab_unmap.lab_mail.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  DO WITH FRAME {&FRAME-NAME}:
     RUN aff_label(101073).
  END.
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME ab_unmap.lab_mess
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ab_unmap.lab_mess w-html WEB.output
PROCEDURE ab_unmap.lab_mess.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  DO WITH FRAME {&FRAME-NAME}:
     RUN aff_label(101011).
  END.
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME ab_unmap.lab_ref
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ab_unmap.lab_ref w-html WEB.output
PROCEDURE ab_unmap.lab_ref.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  DO WITH FRAME {&FRAME-NAME}:
     RUN aff_label(101046).
  END.
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME ab_unmap.livr
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ab_unmap.livr w-html WEB.output
PROCEDURE ab_unmap.livr.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  DO WITH FRAME {&FRAME-NAME}:
     IF buf-adressel <> "" THEN
        {&out} REPLACE(buf-adressel,CHR(10),"<br>").
     ELSE {&out} REPLACE(buf-adressef,CHR(10),"<br>").
  END.
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME ab_unmap.mail
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ab_unmap.mail w-html WEB.output
PROCEDURE ab_unmap.mail.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  DO WITH FRAME {&FRAME-NAME}:
      {&out} IF get-field("emailx") <> "" THEN get-field("emailx") ELSE "&nbsp;".
  END.
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME ab_unmap.mess
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ab_unmap.mess w-html WEB.output
PROCEDURE ab_unmap.mess.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  DO WITH FRAME {&FRAME-NAME}:
      {&out} IF get-field("message") <> "" THEN 
                REPLACE(get-field("message"),CHR(10),"<br>")
             ELSE "&nbsp;".
  END.
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME ab_unmap.Num_com
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ab_unmap.Num_com w-html web.output
PROCEDURE ab_unmap.Num_com.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  DO WITH FRAME {&FRAME-NAME}:
     {&out}  " " cde-prefix "-" last-nodoc.
  END.
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME ab_unmap.ref
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ab_unmap.ref w-html WEB.output
PROCEDURE ab_unmap.ref.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  DO WITH FRAME {&FRAME-NAME}:
     {&out} IF get-field("ref") <> "" THEN get-field("ref")
            ELSE "&nbsp;".
  END.
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME ab_unmap.texte01
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ab_unmap.texte01 w-html WEB.output
PROCEDURE ab_unmap.texte01.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  DO WITH FRAME {&FRAME-NAME}:
      RUN aff_label(101079).
  END.
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME ab_unmap.texte02
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ab_unmap.texte02 w-html WEB.output
PROCEDURE ab_unmap.texte02.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  DO WITH FRAME {&FRAME-NAME}:
      RUN aff_label(101080).
  END.
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME ab_unmap.texte03
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ab_unmap.texte03 w-html WEB.output
PROCEDURE ab_unmap.texte03.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  DO WITH FRAME {&FRAME-NAME}:
      RUN aff_label(101081).
  END.
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME ab_unmap.texte04
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ab_unmap.texte04 w-html WEB.output
PROCEDURE ab_unmap.texte04.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  DO WITH FRAME {&FRAME-NAME}:
      RUN aff_label(101082).
  END.
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME ab_unmap.texte05
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ab_unmap.texte05 w-html WEB.output
PROCEDURE ab_unmap.texte05.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  DO WITH FRAME {&FRAME-NAME}:
      RUN aff_label(101083).
  END.
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME ab_unmap.texte06
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ab_unmap.texte06 w-html WEB.output
PROCEDURE ab_unmap.texte06.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  DO WITH FRAME {&FRAME-NAME}:
      RUN aff_label(101084).
  END.
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME ab_unmap.texte07
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ab_unmap.texte07 w-html WEB.output
PROCEDURE ab_unmap.texte07.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  DO WITH FRAME {&FRAME-NAME}:
      RUN aff_label(101085).
  END.
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME ab_unmap.texte08
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ab_unmap.texte08 w-html WEB.output
PROCEDURE ab_unmap.texte08.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  DO WITH FRAME {&FRAME-NAME}:
      RUN aff_label(101086).
  END.
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME ab_unmap.texte09
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ab_unmap.texte09 w-html WEB.output
PROCEDURE ab_unmap.texte09.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  DO WITH FRAME {&FRAME-NAME}:
      RUN aff_label(101087).
  END.
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&Scoped-define SELF-NAME ab_unmap.texte10
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ab_unmap.texte10 w-html WEB.output
PROCEDURE ab_unmap.texte10.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  DO WITH FRAME {&FRAME-NAME}:
      RUN aff_label(101088).
  END.
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&UNDEFINE SELF-NAME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK w-html 


/* ************************  Main Code Block  ************************* */

/* Standard Main Block that runs adm-create-objects, initializeObject 
 * and process-web-request.
 * The bulk of the web processing is in the Procedure process-web-request
 * elsewhere in this Web object.
 */
{src/web2/template/hmapmain.i}

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


/* **********************  Internal Procedures  *********************** */

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-create-objects w-html  _ADM-CREATE-OBJECTS
PROCEDURE adm-create-objects :
/*------------------------------------------------------------------------------
  Purpose:     Create handles for all SmartObjects used in this procedure.
               After SmartObjects are initialized, then SmartLinks are added.
  Parameters:  <none>
------------------------------------------------------------------------------*/

END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE aff_label w-html 
PROCEDURE aff_label :
/*------------------------------------------------------------------------------
  Purpose:     
  Parameters:  <none>
  Notes:       
------------------------------------------------------------------------------*/

  DEF INPUT PARAMETER num  AS INTEGER NO-UNDO.
  FIND erreur WHERE erreur.noerr = num
                AND erreur.lang  = a-lang NO-LOCK NO-ERROR.

  IF AVAILABLE erreur AND erreur.libel <> "" THEN {&out} erreur.libel.
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE creation_Texte w-html 
PROCEDURE creation_Texte :
/*------------------------------------------------------------------------------
  Purpose:     
  Parameters:  <none>
  Notes:       
------------------------------------------------------------------------------*/
DEF INPUT        PARAMETER buf-lib     AS     CHARACTER NO-UNDO.
DEF INPUT-OUTPUT PARAMETER buf-num     AS     INTEGER   NO-UNDO.

DEF VAR                    i           AS     INTEGER   NO-UNDO.

  PUT "Nombre de lignes : " NUM-ENTRIES(buf-lib,CHR(10)) skip.

  DO i = 1 TO NUM-ENTRIES(buf-lib,CHR(10)):
     PUT "Creation " doce.typdoc "-" doce.prefix "-" doce.nodoc " No : " buf-num " - " ENTRY(i,buf-lib,CHR(10))
         skip.
     CREATE docli.
     ASSIGN docli.nosoc  = doce.nosoc  
            docli.typdoc = doce.typdoc 
            docli.prefix = doce.prefix 
            docli.nodoc  = doce.nodoc  
            docli.noseq  = 99999
            docli.nosui  = buf-num
            docli.libel  = ENTRY(i,buf-lib,CHR(10))
            buf-num      = buf-num + 5.

     PUT "Fin création :" buf-num skip. 
  END.
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE decode_tag w-html 
PROCEDURE decode_tag :
/*------------------------------------------------------------------------------
  Purpose:     
  Parameters:  <none>
  Notes:       
------------------------------------------------------------------------------*/
DEF INPUT  PARAMETER ligne    AS CHARACTER           NO-UNDO.
DEF INPUT  PARAMETER ancre    AS CHARACTER           NO-UNDO.
DEF OUTPUT PARAMETER lst-tag  AS CHARACTER           NO-UNDO.

DEF VAR i              AS INTEGER           NO-UNDO.
DEF VAR j              AS INTEGER           NO-UNDO.
DEF VAR pos            AS INTEGER           NO-UNDO.
DEF VAR tag            AS CHARACTER         NO-UNDO.

REPEAT:
   i = INDEX(ligne,"<!--").
   j = IF INDEX(ligne,"-->") <> 0 THEN INDEX(ligne,"-->") + 2 ELSE LENGTH(ligne).
   IF i = 0 THEN LEAVE.
   tag = SUBSTRING(ligne,i,j - i + 1).
   pos = INDEX(tag,"<!--WSTAG").
   IF pos <> 0 THEN DO:
      pos = INDEX(tag,ancre).
      IF pos <> 0 AND LOOKUP(tag,lst-tag) = 0 THEN lst-tag = lst-tag + "," + tag.
   END.
   ligne = SUBSTRING(ligne,j + 1).
END.
lst-tag = SUBSTRING(lst-tag,2).

END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE decode_tag_mail w-html 
PROCEDURE decode_tag_mail :
/*------------------------------------------------------------------------------
  Purpose:     
  Parameters:  <none>
  Notes:       
------------------------------------------------------------------------------*/

DEF INPUT  PARAMETER ligne    AS CHARACTER           NO-UNDO.
DEF OUTPUT PARAMETER lst-tag  AS CHARACTER           NO-UNDO.

DEF VAR i              AS INTEGER           NO-UNDO.
DEF VAR j              AS INTEGER           NO-UNDO.
DEF VAR pos            AS INTEGER           NO-UNDO.
DEF VAR tag            AS CHARACTER         NO-UNDO.

REPEAT:
   i = INDEX(ligne,"<!--").
   j = IF INDEX(ligne,"-->") <> 0 THEN INDEX(ligne,"-->") + 2 ELSE LENGTH(ligne).
   IF i = 0 THEN LEAVE.
   tag = SUBSTRING(ligne,i,j - i + 1).
   pos = INDEX(tag,"<!--WSTAG").
   IF pos <> 0 THEN IF LOOKUP(tag,lst-tag) = 0 THEN lst-tag = lst-tag + "," + tag.
   ligne = SUBSTRING(ligne,j + 1).
END.
lst-tag = SUBSTRING(lst-tag,2).
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE envoie_mail w-html 
PROCEDURE envoie_mail :
/*------------------------------------------------------------------------------
  Purpose:     
  Parameters:  <none>
  Notes:       
------------------------------------------------------------------------------*/

DEF VAR buf-mail   AS CHARACTER INIT "pao@parvis.ch" NO-UNDO.                         
                         
DEF VAR nom_page        AS CHARACTER      NO-UNDO.
DEF VAR ligne           AS CHARACTER      NO-UNDO.
DEF VAR lst-tag         AS CHARACTER      NO-UNDO.
DEF VAR pos             AS INTEGER        NO-UNDO.
DEF VAR nb              AS INTEGER        NO-UNDO.
DEF VAR buf-mess        AS CHARACTER      NO-UNDO.
DEF VAR txt_aff         AS CHARACTER      NO-UNDO.
                         
buf-mail = get-field("emailx").
IF buf-mail = "" THEN RETURN.

/* OUTPUT THROUGH "/usr/lib/sendmail -t"  */

IF buf-mail <> "" AND cde-prefix = "WEB" THEN OUTPUT TO VALUE("mail/" + cde-prefix + "-" + STRING(last-nodoc)).
ELSE OUTPUT TO VALUE("mail/sauve/" + cde-prefix + "-" + STRING(last-nodoc)).

PUT UNFORMATTED
    "Return-Path: <book@parvis.ch>"       SKIP
    "Reply-To: <book@parvis.ch>"          SKIP
    "From: ""Commande"" <book@parvis.ch>" SKIP
    "To: <" buf-mail ">"                  SKIP
    "Subject: ".


FIND erreur WHERE erreur.noerr = 101114
              AND erreur.lang  = a-lang NO-LOCK NO-ERROR.

IF AVAILABLE erreur AND erreur.libel <> "" THEN 
   PUT UNFORMATTED erreur.libel.

PUT UNFORMATTED SKIP                                                     
    "MIME-version: 1.0"                          SKIP                                             
    "Content-Type: text/html;" skip
    "        charset=""iso-8859-1""" skip
    "Content-Transfer-Encoding: 7bit" skip(1)
    "<HTML><HEAD><title>Commande</title></HEAD>" SKIP
    "<body>"                                     SKIP.

     nom_page = SEARCH("mail_haut.htm").
     IF nom_page <> ? THEN DO:
        INPUT FROM VALUE(nom_page).
        REPEAT:
           IMPORT UNFORMATTED ligne.
           pos = INDEX(ligne,"<!--WSTAG").
           IF TRIM(ligne) BEGINS "<!--" AND pos = 0 THEN NEXT.
           IF pos = 0 THEN PUT UNFORMATTED ligne SKIP.
           ELSE DO:
              RUN decode_tag_mail(ligne,OUTPUT lst-tag).
              DO i = 1 TO NUM-ENTRIES(lst-tag).
                 RUN remplace_mail(ENTRY(i,lst-tag),INPUT-OUTPUT ligne).
              END.
              PUT UNFORMATTED ligne SKIP.
           END.
        END.
     END.
    
     FIND erreur WHERE erreur.noerr = 101009
                    AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
     IF AVAILABLE erreur THEN buf-mess = buf-mess + erreur.libel.
     nom_page = SEARCH("commande_entete.htm").
     buf-mess = buf-mess + "####" .

     nb = NUM-ENTRIES(buf-mess,"#").

     INPUT FROM VALUE(nom_page).
     REPEAT:
        IMPORT UNFORMATTED ligne.
        pos = INDEX(ligne,"<!--WSTAG").
        IF TRIM(ligne) BEGINS "<!--" AND pos = 0 THEN NEXT.
        IF pos = 0 THEN PUT UNFORMATTED ligne SKIP.
        ELSE DO:
           RUN decode_tag(ligne,"label",OUTPUT lst-tag).
           DO i = 1 TO NUM-ENTRIES(lst-tag).
              RUN remplace_tag ("label",nb,ENTRY(i,lst-tag),buf-mess,INPUT-OUTPUT ligne).
           END.
           PUT UNFORMATTED ligne SKIP.
        END.
     END.

     FOR EACH docld WHERE docld.nosoc  = doce.nosoc
                      AND docld.typdoc = doce.typdoc
                      AND docld.prefix = doce.prefix
                      AND docld.nodoc  = doce.nodoc NO-LOCK:
         IF docld.ref = "" THEN NEXT.

         FIND arti WHERE arti.nosoc = docld.nosoc
                     AND arti.ref   = docld.ref NO-LOCK NO-ERROR.

         IF NOT AVAILABLE arti THEN NEXT.
         flag-art = TRUE.

         txt_aff = "&nbsp;".
         txt_aff = txt_aff + "#" + STRING(docld.qtec).
         txt_aff = txt_aff + "#" + arti.titre + "#" + arti.auteur + "#" + ENTRY(1,arti.DESCRIPTION,CHR(10)).
         txt_aff = txt_aff + "#" + STRING(docld.punite,"zz,zz9.99").
         txt_aff = txt_aff + "#" + STRING(docld.rabais,"zz9.99 %").
         txt_aff = txt_aff + "#" + STRING(docld.montne,"zzz,zz9.99").
         txt_aff = txt_aff + "#" + doce.codmon + "#" + docld.ref.

         nom_page = SEARCH("commande_ligne.htm").
         IF nom_page = ? THEN RETURN.
         INPUT FROM VALUE(nom_page).
         REPEAT:
            IMPORT UNFORMATTED ligne.
            pos = INDEX(ligne,"<!--WSTAG").
            IF TRIM(ligne) BEGINS "<!--" AND pos = 0 THEN NEXT.
            IF pos = 0 THEN PUT UNFORMATTED ligne SKIP.
            ELSE DO:
               RUN decode_tag(ligne,"champ",OUTPUT lst-tag).
               DO i = 1 TO NUM-ENTRIES(lst-tag).
                  RUN remplace_tag ("champ",10,ENTRY(i,lst-tag),txt_aff,INPUT-OUTPUT ligne).
               END.
               PUT UNFORMATTED ligne SKIP.
            END.
         END.
     END.


     txt_aff = "".

     FIND erreur WHERE erreur.noerr = 101057
                   AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
     txt_aff = txt_aff + IF NOT AVAILABLE erreur THEN "&nbsp;"
                         ELSE erreur.libel.

     FIND erreur WHERE erreur.noerr = 101012
                   AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
     txt_aff = txt_aff + "#" + erreur.libel
             + "#" + STRING(doce.totme - doce.totqte - doce.totmtn + doce.totme,"->>>,>>9.99").

     FIND erreur WHERE erreur.noerr = 101058
                   AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
     txt_aff = txt_aff + "#" + IF NOT AVAILABLE erreur THEN "&nbsp;"
                         ELSE erreur.libel.

     FIND erreur WHERE erreur.noerr = 101014
                   AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
     txt_aff = txt_aff + "#" + erreur.libel
             + "#" + STRING(doce.totqte + doce.totmtn - doce.totme,"->>>,>>9.99").

     FIND erreur WHERE erreur.noerr = 101059
                   AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
     txt_aff = txt_aff + "#" + IF NOT AVAILABLE erreur THEN "&nbsp;"
                         ELSE erreur.libel.

     FIND erreur WHERE erreur.noerr = 101013
                   AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
     txt_aff = txt_aff + "#" + erreur.libel
             + "#" + STRING(doce.totme,"->>>,>>9.99").

     txt_aff = txt_aff + "#" + doce.codmon.

     nom_page = SEARCH("commande_bas.htm").
     IF nom_page = ? THEN RETURN.
     INPUT FROM VALUE(nom_page).
     REPEAT:
        IMPORT UNFORMATTED ligne.
        pos = INDEX(ligne,"<!--WSTAG").
        IF TRIM(ligne) BEGINS "<!--" AND pos = 0 THEN NEXT.
        IF pos = 0 THEN PUT UNFORMATTED ligne SKIP.
        ELSE DO:
           RUN decode_tag(ligne,"champ",OUTPUT lst-tag).
           DO i = 1 TO NUM-ENTRIES(lst-tag).
              RUN remplace_tag ("champ",10,ENTRY(i,lst-tag),txt_aff,INPUT-OUTPUT ligne).
           END.
           PUT UNFORMATTED ligne SKIP.
        END.
     END.

     nom_page = SEARCH("mail_bas.htm").
     IF nom_page <> ? THEN DO:
        INPUT FROM VALUE(nom_page).
        REPEAT:
           IMPORT UNFORMATTED ligne.
           pos = INDEX(ligne,"<!--WSTAG").
           IF TRIM(ligne) BEGINS "<!--" AND pos = 0 THEN NEXT.
           IF pos = 0 THEN PUT UNFORMATTED ligne SKIP.
           ELSE DO:
              RUN decode_tag_mail(ligne,OUTPUT lst-tag).
              DO i = 1 TO NUM-ENTRIES(lst-tag).
                 RUN remplace_mail(ENTRY(i,lst-tag),INPUT-OUTPUT ligne).
              END.
              PUT UNFORMATTED ligne SKIP.
           END.
        END.
     END.

     PUT UNFORMATTED "</body></html>" SKIP.


/* PUT UNFORMATTED "------=_NextPart_000_0017_01C283E2.B5B327E0" skip(2).  */

OUTPUT CLOSE.

/* OS-COMMAND "cat commande.txt | /usr/lib/sendmail -t".  */

END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE htmOffsets w-html  _WEB-HTM-OFFSETS
PROCEDURE htmOffsets :
/*------------------------------------------------------------------------------
  Purpose:     Runs procedure to associate each HTML field with its
               corresponding widget name and handle.
  Parameters:  
  Notes:       
------------------------------------------------------------------------------*/
  RUN readOffsets ("{&WEB-FILE}":U).
  RUN htmAssociate
    ("article_bas":U,"ab_unmap.article_bas":U,ab_unmap.article_bas:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("article_ent":U,"ab_unmap.article_ent":U,ab_unmap.article_ent:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("article_sais":U,"ab_unmap.article_sais":U,ab_unmap.article_sais:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("client":U,"ab_unmap.client":U,ab_unmap.client:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("lab_cli":U,"ab_unmap.lab_cli":U,ab_unmap.lab_cli:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("Lab_com":U,"ab_unmap.Lab_com":U,ab_unmap.Lab_com:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("lab_livr":U,"ab_unmap.lab_livr":U,ab_unmap.lab_livr:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("lab_mail":U,"ab_unmap.lab_mail":U,ab_unmap.lab_mail:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("lab_mess":U,"ab_unmap.lab_mess":U,ab_unmap.lab_mess:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("lab_ref":U,"ab_unmap.lab_ref":U,ab_unmap.lab_ref:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("livr":U,"ab_unmap.livr":U,ab_unmap.livr:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("mail":U,"ab_unmap.mail":U,ab_unmap.mail:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("mess":U,"ab_unmap.mess":U,ab_unmap.mess:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("Num_com":U,"ab_unmap.Num_com":U,ab_unmap.Num_com:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("ref":U,"ab_unmap.ref":U,ab_unmap.ref:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("texte01":U,"ab_unmap.texte01":U,ab_unmap.texte01:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("texte02":U,"ab_unmap.texte02":U,ab_unmap.texte02:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("texte03":U,"ab_unmap.texte03":U,ab_unmap.texte03:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("texte04":U,"ab_unmap.texte04":U,ab_unmap.texte04:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("texte05":U,"ab_unmap.texte05":U,ab_unmap.texte05:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("texte06":U,"ab_unmap.texte06":U,ab_unmap.texte06:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("texte07":U,"ab_unmap.texte07":U,ab_unmap.texte07:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("texte08":U,"ab_unmap.texte08":U,ab_unmap.texte08:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("texte09":U,"ab_unmap.texte09":U,ab_unmap.texte09:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("texte10":U,"ab_unmap.texte10":U,ab_unmap.texte10:HANDLE IN FRAME {&FRAME-NAME}).
END PROCEDURE.


/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE outputHeader w-html 
PROCEDURE outputHeader :
/*------------------------------------------------------------------------
  Purpose:     Output the MIME header, and any "cookie" information needed 
               by this procedure.  
  Parameters:  <none>
  Notes:       In the event that this Web object is state-aware, this is 
               a good place to set the WebState and WebTimeout attributes.
------------------------------------------------------------------------*/

  /* To make this a state-aware Web object, pass in the timeout period
   * (in minutes) before running outputContentType.  If you supply a 
   * timeout period greater than 0, the Web object becomes state-aware 
   * and the following happens:
   *
   *   - 4GL variables webState and webTimeout are set
   *   - a cookie is created for the broker to id the client on the return trip
   *   - a cookie is created to id the correct procedure on the return trip
   *
   * If you supply a timeout period less than 1, the following happens:
   *
   *   - 4GL variables webState and webTimeout are set to an empty string
   *   - a cookie is killed for the broker to id the client on the return trip
   *   - a cookie is killed to id the correct procedure on the return trip
   *
   * For example, set the timeout period to 5 minutes.
   *
   *   setWebState (5.0).
   */
    
  /* Output additional cookie information here before running outputContentType.
   *   For more information about the Netscape Cookie Specification, see
   *   http://home.netscape.com/newsref/std/cookie_spec.html  
   *   
   *   Name         - name of the cookie
   *   Value        - value of the cookie
   *   Expires date - Date to expire (optional). See TODAY function.
   *   Expires time - Time to expire (optional). See TIME function.
   *   Path         - Override default URL path (optional)
   *   Domain       - Override default domain (optional)
   *   Secure       - "secure" or unknown (optional)
   * 
   *   The following example sets custNum=23 and expires tomorrow at (about)
   *   the same time but only for secure (https) connections.
   *      
   *   RUN SetCookie IN web-utilities-hdl 
   *     ("custNum":U, "23":U, TODAY + 1, TIME, ?, ?, "secure":U).
   */ 
  output-content-type ("text/html":U).
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE process-web-request w-html 
PROCEDURE process-web-request :
/*------------------------------------------------------------------------
  Purpose:     Process the web request.
  Notes:       
------------------------------------------------------------------------*/
       /* STEP 0 -
   * Output the MIME header and set up the object as state-less or state-aware. 
   * This is required if any HTML is to be returned to the browser. 
   *
   * NOTE: Move 'RUN outputHeader.' to the GET section below if you are going
   * to simulate another Web request by running a Web Object from this
   * procedure.  Running outputHeader precludes setting any additional cookie
   * information.
   */ 
  
  ASSIGN buf-noadr  = INTEGER(ENTRY(1,get-cookie("SessionId")))
         buf-csmt   = 0
         buf-prefix = ENTRY(2,get-cookie("SessionId"))
         buf-nodoc  = INTEGER(ENTRY(3,get-cookie("SessionId"))).

  IF NUM-ENTRIES(get-cookie("SessionId")) >= 4 THEN cde-prefix = ENTRY(4,get-cookie("SessionId")).
  ELSE cde-prefix = "WEB".

  a-lang = INTEGER(get-field("lang")).
  IF a-lang = 0 THEN a-lang = 2.

  RUN outputHeader.
  
  /* Describe whether to receive FORM input for all the fields.  For example,
   * check particular input fields (using GetField in web-utilities-hdl). 
   * Here we look at REQUEST_METHOD. 
   */
  IF REQUEST_METHOD = "POST":U THEN DO:
    /* STEP 1 -
     * Copy HTML input field values to the Progress form buffer. */
    RUN inputFields.
    
    /* STEP 2 -
     * Open the database or SDO query and and fetch the first record. */ 
    RUN findRecords.
    
    /* STEP 3 -    
     * AssignFields will save the data in the frame.
     * (it automatically upgrades the lock to exclusive while doing the update)
     * 
     *  If a new record needs to be created set AddMode to true before 
        running assignFields.  
     *     setAddMode(TRUE).   
     * RUN assignFields. */
    
    /* STEP 4 -
     * Decide what HTML to return to the user. Choose STEP 4.1 to simulate
     * another Web request -OR- STEP 4.2 to return the original form (the
     * default action).
     *
     * STEP 4.1 -
     * To simulate another Web request, change the REQUEST_METHOD to GET
     * and RUN the Web object here.  For example,
     *
     *  ASSIGN REQUEST_METHOD = "GET":U.
     *  RUN run-web-object IN web-utilities-hdl ("myobject.w":U).
     */
     
    /* STEP 4.2 -
     * To return the form again, set data values, display them, and output 
     * them to the WEB stream.  
     *
     * STEP 4.2a -
     * Set any values that need to be set, then display them. */
    RUN displayFields.
   
    /* STEP 4.2b -
     * Enable objects that should be enabled. */
    RUN enableFields.

    /* STEP 4.2c -
     * OUTPUT the Progress form buffer to the WEB stream. */
    RUN outputFields.
    
  END. /* Form has been submitted. */
 
  /* REQUEST-METHOD = GET */ 
  ELSE DO:
    /* This is the first time that the form has been called. Just return the
     * form.  Move 'RUN outputHeader.' here if you are going to simulate
     * another Web request. */ 
   
    /* STEP 1 -
     * Open the database or SDO query and and fetch the first record. */ 
    RUN findRecords.
    
    /* Return the form again. Set data values, display them, and output them
     * to the WEB stream.  
     *
     * STEP 2a -
     * Set any values that need to be set, then display them. */
    RUN displayFields.

    /* STEP 2b -
     * Enable objects that should be enabled. */
    RUN enableFields.

    FIND LAST doce WHERE doce.nosoc  = 1 
                     AND doce.typdoc = "CC"
                     AND doce.prefix = cde-prefix
                     USE-INDEX docekey NO-LOCK NO-ERROR .

    last-nodoc = IF NOT AVAILABLE doce THEN 1
                 ELSE doce.nodoc + 1.

    FIND FIRST doce WHERE doce.nosoc  = 1 
                      AND doce.typdoc = "PA"
                      AND doce.prefix = buf-prefix
                      AND doce.nodoc  = buf-nodoc
                      NO-ERROR.

    FIND FIRST docld WHERE docld.nosoc  = doce.nosoc
                       AND docld.typdoc = doce.typdoc
                       AND docld.prefix = doce.prefix
                       AND docld.nodoc  = doce.nodoc
                       AND docld.ref   <> "" NO-LOCK NO-ERROR.
    flag-lgdoc = AVAILABLE docld.

    IF NOT flag-lgdoc THEN DELETE doce.
    ELSE DO:

        ASSIGN buf-typdoc  = "PA"
               doce.typdoc = "CC".

        CREATE wk-doce.
        wk-doce.typdoc = "PA".
        BUFFER-COPY doce EXCEPT typdoc TO wk-doce.

        ASSIGN doce.prefix = cde-prefix
               doce.nodoc  = last-nodoc
               doce.cliv   = "COLD"
               doce.heure  = TIME
               doce.dval   = TODAY
               doce.datdoc = TODAY.

        doce.conc[1] = get-field("ref").

        FOR EACH docld WHERE docld.nosoc  = doce.nosoc  
                         AND docld.typdoc = buf-typdoc 
                         AND docld.prefix = buf-prefix
                         AND docld.nodoc  = buf-nodoc:

            ASSIGN docld.typdoc = doce.typdoc
                   docld.prefix = doce.prefix
                   docld.nodoc  = doce.nodoc.

    /*         FIND stoc WHERE stoc.nosoc  = docld.nosoc                 */
    /*                     AND stoc.ref    = docld.ref                   */
    /*                     AND stoc.nostoc = docld.nostoc NO-ERROR.      */
    /*                                                                   */
    /*         stoc.qres = stoc.qres + docld.qteumb.                     */
    /*                                                                   */
    /*         FOR EACH docnom WHERE docnom.nosoc  = docld.nosoc         */
    /*                           AND docnom.typdoc = buf-typdoc          */
    /*                           AND docnom.prefix = buf-prefix          */
    /*                           AND docnom.nodoc  = buf-nodoc           */
    /*                           AND docnom.noseq  = docld.noseq:        */
    /*                                                                   */
    /*             ASSIGN docnom.typdoc = doce.typdoc                    */
    /*                    docnom.prefix = doce.prefix                    */
    /*                    docnom.nodoc  = doce.nodoc.                    */
    /*             IF NOT docnom.tenu THEN NEXT.                         */
    /*                                                                   */
    /*             FIND stoc WHERE stoc.nosoc  = docld.nosoc             */
    /*                         AND stoc.ref    = docnom.comp             */
    /*                         AND stoc.nostoc = docld.nostoc NO-ERROR.  */
    /*                                                                   */
    /*             stoc.qres = stoc.qres + docld.qteumb * docnom.qutil.  */
    /*         END.                                                      */

        END.

    /*    FOR EACH docli WHERE docli.nosoc  = doce.nosoc      */
    /*                     AND docli.typdoc = doce.typdoc     */
    /*                     AND docli.prefix = doce.prefix     */
    /*                     AND docli.nodoc  = doce.nodoc      */
    /*                     AND docli.noseq  = 99999:          */
    /*        DELETE docli.                                   */
    /*    END.                                                */

        IF get-field("civilf") <> "" THEN buf-adressef = buf-adressef + CHR(10) + get-field("civilf").
        IF get-field("nomfx")   <> "" THEN buf-adressef = buf-adressef + CHR(10) + get-field("nomfx").
        IF get-field("adr1f")  <> "" THEN buf-adressef = buf-adressef + CHR(10) + get-field("adr1f").
        IF get-field("adr2f")  <> "" THEN buf-adressef = buf-adressef + CHR(10) + get-field("adr2f").
        IF get-field("adr3f")  <> "" THEN buf-adressef = buf-adressef + CHR(10) + get-field("adr3f").
        IF get-field("localf") <> "" THEN buf-adressef = buf-adressef + CHR(10) + get-field("localf").
        IF get-field("paysf")  <> "" THEN buf-adressef = buf-adressef + CHR(10) + get-field("paysf").
        IF get-field("telf")   <> "" THEN buf-adressef = buf-adressef + CHR(10) + get-field("telff").
        buf-adressef = SUBSTRING(buf-adressef,2).
        
        IF get-field("civill") <> "" THEN buf-adressel = buf-adressel + CHR(10) + get-field("civill").
        IF get-field("nomlx")   <> "" THEN buf-adressel = buf-adressel + CHR(10) + get-field("nomlx").
        IF get-field("adr1l")  <> "" THEN buf-adressel = buf-adressel + CHR(10) + get-field("adr1l").
        IF get-field("adr2l")  <> "" THEN buf-adressel = buf-adressel + CHR(10) + get-field("adr2l").
        IF get-field("adr3l")  <> "" THEN buf-adressel = buf-adressel + CHR(10) + get-field("adr3l").
        IF get-field("locall") <> "" THEN buf-adressel = buf-adressel + CHR(10) + get-field("locall").
        IF get-field("paysl")  <> "" THEN buf-adressel = buf-adressel + CHR(10) + get-field("paysl").
        buf-adressel = SUBSTRING(buf-adressel,2).
        
        IF doce.noadrf <> 1000 AND doce.noadrf <> 1001 THEN DO:
           FIND adra WHERE adra.nosoc = doce.nosoc
                       AND adra.noadr = doce.noadrf
                       AND adra.csmt  = doce.csmtf  NO-LOCK NO-ERROR.
           IF AVAILABLE adra THEN DO:
              buf-adresse = "".
              IF adra.civil <> "" THEN buf-adresse = buf-adresse + CHR(10) + adra.civil.
              IF adra.nom   <> "" THEN buf-adresse = buf-adresse + CHR(10) + adra.nom.
              IF adra.adr1  <> "" THEN buf-adresse = buf-adresse + CHR(10) + adra.adr1.
              IF adra.adr2  <> "" THEN buf-adresse = buf-adresse + CHR(10) + adra.adr2.
              IF adra.adr3  <> "" THEN buf-adresse = buf-adresse + CHR(10) + adra.adr3.
              IF adra.local <> "" THEN buf-adresse = buf-adresse + CHR(10) + adra.local.
              IF adra.pays  <> "" THEN buf-adresse = buf-adresse + CHR(10) + adra.pays.
              IF adra.tel   <> "" THEN buf-adresse = buf-adresse + CHR(10) + adra.tel.
              buf-adresse = SUBSTRING(buf-adresse,2).
           END.

           IF buf-adresse = buf-adressef THEN buf-adressef = "".
        END.

        j = 5.

        IF buf-adressef = "" THEN buf-adressef = buf-adresse.

        OUTPUT TO VALUE("adresse.log") APPEND.
        PUT unformatted SKIP doce.prefix "-" doce.nodoc " " doce.noadrf  "/" doce.csmtf SKIP
            "Adresse facturation :  " num-entries(buf-adressef,CHR(10)) SKIP
            buf-adressef skip
            "Adresse de livraison : " num-entries(buf-adressel,chr(10)) SKIP
            buf-adressel skip
            "===============================" skip.

        IF buf-adressef <> "" THEN DO:
           buf-lib = CHR(10) + "Adresse Client :" + CHR(10)
                             + "================" + CHR(10).
           RUN creation_texte(buf-lib,INPUT-OUTPUT j).
           buf-lib = buf-adressef.
           RUN creation_texte(buf-lib,INPUT-OUTPUT j).
           put unformatted "Passage creation buf-adressef" skip.
        END.

        IF buf-adressel <> "" THEN DO:
           buf-lib = CHR(10) + "Adresse de Livraison :" + CHR(10)
                             + "======================" + CHR(10).
           RUN creation_texte(buf-lib,INPUT-OUTPUT j).
           buf-lib = buf-adressel.
           RUN creation_texte(buf-lib,INPUT-OUTPUT j).
           put unformatted "Passage creation buf-adressel" skip.

        END.


        IF get-field("emailx") <> "" THEN DO:
           buf-lib = CHR(10) + "E-Mail  :" + CHR(10)
                             + "========" + CHR(10).
           RUN creation_texte(buf-lib,INPUT-OUTPUT j).
           buf-lib = get-field("emailx").
           RUN creation_texte(buf-lib,INPUT-OUTPUT j).
        END.

        IF get-field("message") <> "" THEN DO:
           buf-lib = CHR(10) + "Remarques :" + CHR(10)
                             + "===========" + CHR(10).
           RUN creation_texte(buf-lib,INPUT-OUTPUT j).
           buf-lib = get-field("message").
           RUN creation_texte(buf-lib,INPUT-OUTPUT j).
        END.

        output close.

        FOR EACH dliv WHERE dliv.nosoc  = doce.nosoc 
                        AND dliv.typdoc = buf-typdoc 
                        AND dliv.prefix = buf-prefix
                        AND dliv.nodoc  = buf-nodoc:
            ASSIGN dliv.typdoc = doce.typdoc
                   dliv.prefix = doce.prefix
                   dliv.nodoc  = doce.nodoc
                   dliv.delait = ?
                   dliv.deldd  = ?.
        END.

        doce.totme = doce.totmtn.
        RUN tdrrarr.p (doce.codmon,3,INPUT-OUTPUT doce.totme).

        ASSIGN doce.totmb = doce.totme * doce.cours / doce.unit.
               doce.totmb = ROUND(doce.totmb,2).

        FIND adrd WHERE adrd.nosoc = doce.nosoc
                    AND adrd.noadr = doce.noadrf
                    AND adrd.csmt  = doce.csmtf NO-ERROR.

        adrd.senc = adrd.senc + doce.totme.

        IF adrd.esc    <> 0 OR
           adrd.echesc <> 0 OR
           adrd.echnet <> 0 THEN ASSIGN buf-esc    = adrd.esc
                                        buf-echesc = adrd.echesc
                                        buf-echnet = adrd.echnet
                                        buf-echle  = adrd.echle.
        ELSE DO:

           FIND adrd WHERE adrd.nosoc = doce.nosoc
                       AND adrd.noadr = doce.noadrl
                       AND adrd.csmt  = doce.csmtl NO-ERROR.

           IF adrd.esc    <> 0 OR
              adrd.echesc <> 0 OR
              adrd.echnet <> 0 THEN ASSIGN buf-esc    = adrd.esc
                                           buf-echesc = adrd.echesc
                                           buf-echnet = adrd.echnet
                                           buf-echle  = adrd.echle.
           ELSE DO:
              FIND parmt WHERE parmt.nosoc  = doce.nosoc
                           AND parmt.nomuti = ""
                           AND parmt.nompar = "CONDPPARDEFAUT" + doce.prefix
                           NO-LOCK NO-ERROR.
              IF NOT AVAILABLE parmt THEN
                 FIND parmt WHERE parmt.nosoc  = 0
                              AND parmt.nomuti = ""
                              AND parmt.nompar = "CONDPPARDEFAUT" + doce.prefix
                              NO-LOCK NO-ERROR.
              IF AVAILABLE parmt THEN
                 ASSIGN buf-parmt  = parmt.valpar
                        i = INDEX(buf-parmt,",")
                        buf-esc    = INTEGER(SUBSTRING(buf-parmt,1,i - 1))
                        buf-parmt  = SUBSTRING(buf-parmt,i + 1)
                        i = INDEX(buf-parmt,",")
                        buf-echesc = INTEGER(SUBSTRING(buf-parmt,1,i - 1))
                        buf-parmt  = substring(buf-parmt,i + 1)
                        i = INDEX(buf-parmt,",")
                        buf-echnet = INTEGER(SUBSTRING(buf-parmt,1,i - 1))
                        buf-echle  = INTEGER(SUBSTRING(buf-parmt,i + 1)).
           END.
        END.

        IF buf-esc <> 0 OR buf-echesc <> 0 OR buf-echnet = 0 THEN DO:
           CREATE condp.
           ASSIGN condp.nosoc  = doce.nosoc
                  condp.typdoc = doce.typdoc
                  condp.prefix = doce.prefix
                  condp.nodoc  = doce.nodoc
                  condp.nosui  = 5
                  condp.esc    = buf-esc
                  condp.nbjour = buf-echesc.
        END.

        IF buf-echnet <> 0 THEN DO:
           CREATE condp.
           ASSIGN condp.nosoc  = doce.nosoc
                  condp.typdoc = doce.typdoc
                  condp.prefix = doce.prefix
                  condp.nodoc  = doce.nodoc
                  condp.nosui  = 10
                  condp.nbjour = buf-echnet
                  condp.jour   = buf-echle.
        END.

        FIND adra WHERE adra.nosoc = doce.nosoc
                    AND adra.noadr = doce.noadrf
                    AND adra.csmt  = doce.csmtf NO-ERROR.

        sav-lang = a-lang.
        a-lang = adra.lang.

        FOR EACH docld WHERE docld.nosoc  = doce.nosoc  
                         AND docld.typdoc = doce.typdoc 
                         AND docld.prefix = doce.prefix
                         AND docld.nodoc  = doce.nodoc:
            RUN facrliba.p.
        END.
    END.

    a-lang = sav-lang.

    RUN envoie_mail.


/*     RUN run-web-object IN web-utilities-hdl ("commande.w":U).  */
/*     RETURN.                                                    */

    /* STEP 2c -
     * OUTPUT the Progress from buffer to the WEB stream. */
    RUN outputFields.
  END. 
  
  /* Show error messages. */
  IF AnyMessage() THEN 
  DO:
     /* ShowDataMessage may return a Progress column name. This means you
      * can use the function as a parameter to HTMLSetFocus instead of 
      * calling it directly.  The first parameter is the form name.   
      *
      * HTMLSetFocus("document.DetailForm",ShowDataMessages()). */
     ShowDataMessages().
  END.
 
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE remplace_mail w-html 
PROCEDURE remplace_mail :
/*------------------------------------------------------------------------------
  Purpose:     
  Parameters:  <none>
  Notes:       
------------------------------------------------------------------------------*/

DEF INPUT        PARAMETER tag      AS   CHARACTER        NO-UNDO.       
DEF INPUT-OUTPUT PARAMETER ligne    AS   CHARACTER        NO-UNDO.


CASE tag:
    WHEN "<!--WSTAG name=~"lab_cli~" -->"  THEN DO:
       FIND erreur WHERE erreur.noerr = 101090
                     AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
       IF AVAILABLE erreur THEN ligne = REPLACE(ligne,tag,erreur.libel).
    END.
    WHEN "<!--WSTAG name=~"lab_livr~" -->" THEN DO:
       FIND erreur WHERE erreur.noerr = 101091
                     AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
       IF AVAILABLE erreur THEN ligne = REPLACE(ligne,tag,erreur.libel).
    END.
    WHEN "<!--WSTAG name=~"lab_ref~" -->"  THEN DO:
        FIND erreur WHERE erreur.noerr = 101046
                      AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
        IF AVAILABLE erreur THEN ligne = REPLACE(ligne,tag,erreur.libel).
    END.
    WHEN "<!--WSTAG name=~"lab_mess~" -->" THEN DO:
        FIND erreur WHERE erreur.noerr = 101011
                      AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
        IF AVAILABLE erreur THEN ligne = REPLACE(ligne,tag,erreur.libel).
    END.
    WHEN "<!--WSTAG name=~"lab_mail~" -->" THEN DO:
        FIND erreur WHERE erreur.noerr = 101073
                      AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
        IF AVAILABLE erreur THEN ligne = REPLACE(ligne,tag,erreur.libel).
    END.
    WHEN "<!--WSTAG name=~"lab_com~" -->"  THEN DO:
       FIND erreur WHERE erreur.noerr = 101046
                     AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
       IF AVAILABLE erreur THEN ligne = REPLACE(ligne,tag,erreur.libel).
    END.
    WHEN "<!--WSTAG name=~"texte01~" -->"  THEN DO:
       FIND erreur WHERE erreur.noerr = 101105
                     AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
       IF AVAILABLE erreur THEN ligne = REPLACE(ligne,tag,erreur.libel).
    END.
    WHEN "<!--WSTAG name=~"texte02~" -->"  THEN DO:
       FIND erreur WHERE erreur.noerr = 101106
                     AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
       IF AVAILABLE erreur THEN ligne = REPLACE(ligne,tag,erreur.libel).
    END.

    WHEN "<!--WSTAG name=~"mess~" -->" THEN DO:
        IF get-field("message") <> "" THEN 
            ligne = REPLACE(ligne,tag,REPLACE(get-field("message"),CHR(10),"<br>")).
        ELSE ligne = REPLACE(ligne,tag,"&nbsp;").
    END.
    WHEN "<!--WSTAG name=~"mail~" -->" THEN DO:
        IF get-field("mail") <> "" THEN 
            ligne = REPLACE(ligne,tag,get-field("emailx")).
        ELSE ligne = REPLACE(ligne,tag,"&nbsp;").
    END.
    WHEN "<!--WSTAG name=~"ref~" -->" THEN DO:
        IF get-field("ref") <> "" THEN 
            ligne = REPLACE(ligne,tag,get-field("ref")).
        ELSE ligne = REPLACE(ligne,tag,"&nbsp;").
    END.
    WHEN "<!--WSTAG name=~"livr~" -->" THEN DO:
        IF buf-adressel <> "" THEN 
            ligne = REPLACE(ligne,tag,REPLACE(buf-adressel,CHR(10),"<br>")).
        ELSE ligne = REPLACE(ligne,tag,REPLACE(buf-adressef,CHR(10),"<br>")).
    END.
    WHEN "<!--WSTAG name=~"client~" -->" THEN DO:
        IF buf-adressef <> "" THEN 
            ligne = REPLACE(ligne,tag,REPLACE(buf-adressef,CHR(10),"<br>")).
        ELSE ligne = REPLACE(ligne,tag,"&nbsp;").
    END.
    WHEN "<!--WSTAG name=~"num_com~" -->" THEN
            ligne = REPLACE(ligne,tag,"WEB-" + STRING(last-nodoc)).
END CASE.

END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE remplace_tag w-html 
PROCEDURE remplace_tag :
/*------------------------------------------------------------------------------
  Purpose:     
  Parameters:  <none>
  Notes:       
------------------------------------------------------------------------------*/
DEF INPUT        PARAMETER ancre    AS   CHARACTER        NO-UNDO.       
DEF INPUT        PARAMETER nombre   AS   INTEGER          NO-UNDO.       
DEF INPUT        PARAMETER tag      AS   CHARACTER        NO-UNDO.       
DEF INPUT        PARAMETER texte    AS   CHARACTER        NO-UNDO.       
DEF INPUT-OUTPUT PARAMETER ligne    AS   CHARACTER        NO-UNDO.
DEF VAR i          AS   INTEGER                    NO-UNDO.
DO i = 1 TO nombre:
   IF INDEX(tag,ancre + STRING(i,"99")) <> 0 THEN ligne = REPLACE(ligne,tag,ENTRY(i,texte,"#")).
END.

END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

